//import beautiful.butterfly.drds.datasource.connection_contexts.pooled.ConnectionContexts;
//import beautiful.butterfly.drds.datasource.connection_contexts.pooled.ConnectionContextsFactory;
package beautiful.butterfly.drds.datasource.connection_contexts.spi;

import beautiful.butterfly.drds.datasource.connection_contexts.api.AbstractConnectionContextsFactory;
import beautiful.butterfly.drds.datasource.connection_contexts.api.IRowDataMapList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.Executors;

public class Test {
    public static Logger logger = LoggerFactory.getLogger(Test.class);

    public static void main(String[] args) throws Exception {

        ConnectionContextsFactory connectionContextsFactory = new ConnectionContextsFactory();
        ConnectionContexts.scheduledExecutorService = Executors.newScheduledThreadPool(10);
        ConnectionContexts connectionContexts = connectionContextsFactory.createConnectionContexts(AbstractConnectionContextsFactory.getProperties());

        connectionContexts.init();
        for (int i = 0; i < 2; i++) {
            ConnectionContext connectionContext = connectionContexts.getConnectionContext();
            IRowDataMapList rowDataMapList = connectionContext.createParameterizedSql("select 1").executeQuery();
            rowDataMapList.next();
            logger.info(rowDataMapList.getString(1));
            rowDataMapList.close();
            connectionContext.close();

        }
    }


}
